/*
 ------------------------------------------------------------------------------
 Copyright (C) 2006-2007 Team Blur.

 This file is part of the Quantum Engine source code.

 The Quantum Engine source code is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or (at your
 option) any later version.

 The Quantum Engine source code is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 more details.

 You should have received a copy of the GNU General Public License along with
 the Quantum Engine source code; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 ------------------------------------------------------------------------------
*/


#ifndef __FRAMEWORK_SOUND_H__
#define __FRAMEWORK_SOUND_H__


// Sound channels must be defined by the game code.
// This is the only channel used internally by the sound system.
#define SOUND_CHANNEL_ANY			0

typedef struct soundShader_s		soundShader_t;

typedef struct {
	bool					initialized;

	const char *			vendorString;
	const char *			rendererString;
	const char *			versionString;
	const char *			extensionsString;
	const char *			alcExtensionsString;

	bool					efxAvailable;

	int						maxAuxiliarySends;

	const char *			deviceList;
	const char *			deviceName;

	int						mixerFrequency;
	int						mixerRefresh;
	int						mixerSync;
} alConfig_t;

/*
 ==============================================================================

 FUNCTIONS EXPORTED BY THE ENGINE

 ==============================================================================
*/

typedef struct {
	// Loads and prepares environmental reverberation effects for a given map
	void					(*LoadReverbs)(const char *name);

	// Loads and registers the given sound shader
	soundShader_t *			(*RegisterSoundShader)(const char *name);

	// Emitters are used to play sounds in the world.
	// When an emitter is freed all sounds can continue playing until
	// completed, or they can be stopped immediately.
	int						(*AddSoundEmitter)(int listenerId, const odVec3 &position, const odVec3 &velocity, bool underwater, int area);
	void					(*UpdateSoundEmitter)(int emitterHandle, int listenerId, const odVec3 &position, const odVec3 &velocity, bool underwater, int area);
	void					(*FreeSoundEmitter)(int emitterHandle, bool stopSounds);

	// Plays a sound on the given channel of the given emitter.
	// SOUND_CHANNEL_ANY will never override a playing sound.
	// Returns the length of the sound in milliseconds, or 0 if the sound could
	// not be played for some reason.
	int						(*PlaySoundOnEmitter)(int emitterHandle, int channelId, soundShader_t *soundShader);

	// Stops all sounds playing on the given channel of the given emitter.
	// SOUND_CHANNEL_ANY will stop all playing sounds.
	void					(*StopSoundOnEmitter)(int emitterHandle, int channelId);

	// Updates listener parameters
	void					(*PlaceListener)(int listenerId, int time, const odVec3 &position, const odVec3 &velocity, const odMat3 &axis, bool underwater, int area);

	// Returns a shake amplitude for the current listener position
	float					(*ShakeAmplitudeForListener)(void);

	// Local sounds always play at full volume with no spatialization
	void					(*PlayLocalSound)(soundShader_t *soundShader);

	// Background music streaming.
	// Note that only OGG files are supported.
	void					(*PlayBackgroundMusic)(const char *name);
	void					(*StopBackgroundMusic)(void);

	// Allows other subsystems to get the current AL configuration
	void					(*GetALConfig)(alConfig_t *config);
} odSound_t;


#endif	// __FRAMEWORK_SOUND_H__
